const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
      active:0,
      offset: 0,
      limit:10,
      newcomerReward:[],
      vanTab:[{
        title:'全部',
        id:0
      },{
        title:'待结算',
        id:1
      },{
        title:'已结算',
        id:2
      }],
      yz_basic_info:{},
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      this.setData({
        yz_basic_info:wx.getStorageSync('yz_basic_info'),
        integral:wx.getStorageSync('integral'),
        balance:wx.getStorageSync('balance')
      })
      this.getData();
    },
    getData () {
      let baseUrl = app.getNetAddresss(`plugin.newcomer-fission.frontend.controllers.list.get-pool-list`);
      app._getNetWork({
        url: baseUrl,
        data: {
          offset: this.data.offset,
          status: this.data.active,
          limit:this.data.limit
        },
        success: (respone) => {
          if (respone.data.result !== 1) {
            wx.showToast({
              title: respone.data.msg,
            });
            return false;
          }
          let res = respone.data.data;
          let newcomerReward = [];
          newcomerReward = this.data.newcomerReward.concat(res.list);
          this.setData({
            newcomerReward,
            count:res.count,
            page: ++this.data.page,
          });
        }
      });
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
      if(this.data.newcomerReward.length >= this.data.count){
        return true;
      }
      this.setData({
        offset:this.data.offset+1
      })
      this.getData();
    },
    changeTabs(evt) {
      this.setData({
        offset: 0,
        active:evt.detail.name,
        newcomerReward:[]
      })
      this.getData();
    }
})